package com.xique.door.api.factory;

import com.xique.common.core.domain.R;
import com.xique.common.core.web.domain.AjaxResult;
import com.xique.door.api.RemoteWxLoginService;
import com.xique.door.api.model.LoginAppUser;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;

import java.util.Map;

/**
 * @author shd
 * @create 2021/12/31 10:50
 */
@Component
public class RemoteWxLoginFallbackFactory implements FallbackFactory<RemoteWxLoginService> {

    private static final Logger log = LoggerFactory.getLogger(RemoteWxLoginFallbackFactory.class);

    @Override
    public RemoteWxLoginService create(Throwable throwable) {

        log.error("门禁服务调用失败:{}", throwable.getMessage());

        return new RemoteWxLoginService() {

            @Override
            public R<String> getPhone(String code) {
                return R.fail("获取微信手机号失败:" + throwable.getMessage());
            }

            @Override
            public R<LoginAppUser> login(String phone, String code) {
                return R.fail("微信登录失败:" + throwable.getMessage());
            }

            @Override
            public R<LoginAppUser> verificationCode(String phone, String code) {
                return  R.fail("验证码登录失败:" + throwable.getMessage());
            }

            @Override
            public R<String> sendAuthCode(String phone) {
                return  R.fail("短信验证码获取失败:" + throwable.getMessage());
            }
        };

    }
}
